var button = {
	options :
	{
		tooltip: "Misure Areali",
		iconCls: "measurearea",
		enableToggle: true,
		pressed: false,
		control: new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon, {
			persist: true,
			eventListeners: {
				measure: function(evt){
					var out = '';
					out += 'Area: ' + evt.measure.toFixed(3) + " " + evt.units + "2";
					Ext.getCmp("bbar_measure").setText(out);
				},
				measurepartial: function(evt){
					var out = '';
					out += 'Area: ' + evt.measure.toFixed(3) + " " + evt.units + "2";
					Ext.getCmp("bbar_measure").setText(out);
				}
			}
		}),
		id: "measurearea",
		toggleGroup: "toolGroup"

	},
	create : function(options) {
		CWN2.base.map.addControl(options.control);
		
		// aggiungo alla statusbar il campo per la visualizzazione delle misure
		if (!Ext.getCmp("bbar_measure")) {
			var item = {
				id: 'bbar_measure',
				text: "",
				width: 200,
				xtype: "tbtext"
			};
			Ext.getCmp("statusbar").add(item);
		}
		
		return new GeoExt.Action(options);
	}
};

CWN2.ToolbarBuilder.itemDefs[button.options.id] = button;

